package com.wn.web;

import com.wn.VO.CityVO;
import com.wn.common.pojo.*;
import com.wn.service.CityService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @BelongsProject: hurricane_travel
 * @BelongsPackage: com.wn.web
 * @Author: lhq
 * @Description: 城市控制层
 */
@RestControllerAdvice
@RequestMapping("city")
public class CityController {

    private static final Logger log = LoggerFactory.getLogger(CityController.class);

    @Autowired
    private CityService cityService;

    /**
     * 获得所有城市的信息
     * @return
     */
    @PostMapping("getAllCity")
    public Rsp getAllCity(){
        return cityService.getAllCity();
    }

    /*级联搜索城市（私人定制菜单）*/
    @PostMapping("getCityList")
    public Rsp getCityList(@RequestBody ReqCity reqCity){
        log.info("搜索的城市是{}",reqCity.toString());
        return cityService.getCityList(reqCity);
    }

    @PostMapping("getCityByName")
    public Rsp getCityByName(@RequestBody CityVO cityVO){
        System.out.println(cityVO.getCityName());
        Rsp rsp = cityService.getCityByName(cityVO.getCityName());
        return rsp;
    }
    /*级联搜索目的地*/
    @PostMapping("getShowCityList")
    public Rsp getShowCityList(@RequestBody ReqDestination deqtination){
        log.info("搜索的景区是{}",deqtination);
        return cityService.getDestinationByName(deqtination);
    }

    @PostMapping("getCityByRegionCode")
    public Rsp getCityByRegionCode(@RequestBody City city){
        log.info("code",city.getRegioncode());
        return cityService.getCityByRegionCode(city.getRegioncode());

    }

}
